﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OracleClient;

namespace sqlconnectionstudy
{
    public partial class oraclechange : Form
    {
        
        
        public oraclechange()
        {
            InitializeComponent();
           
        }

        private void oracleconnection_Click(object sender, EventArgs e)
        {
            string ConnectionString = "Data Source=orcl;Persist Security Info=True;User ID=viot;Password=viot ";
            OracleConnection conn = new OracleConnection(ConnectionString);
            bool IsCanConnectioned = false;
            try
            {
                conn.Open();
                IsCanConnectioned = true;
            }
            catch
            {
                IsCanConnectioned = false;
            }
            finally
            {
                conn.Close();//关闭打开的连接
            }

            if (IsCanConnectioned)
            {
                MessageBox.Show("连接成功");
            }
            else
            {
                MessageBox.Show("连接不成功");
            }
        }

        private void oracleselect_Click(object sender, EventArgs e)
        {
            //string selectsql = "select * from ZHXT_TX_RY_RXZP where ZPBH=ZP10000448";
          
        }

        private void oraclechange_Load(object sender, EventArgs e)
        {
            string connstring = "Data Source=orcl;Persist Security Info=True;User ID=viot;Password=viot";
            OracleConnection con = new OracleConnection(connstring);
            con.Open();
            string sql="select * from ZHXT_TX_RY_RXZP where ZPBH='ZP10000500'";
            OracleCommand cmd = new OracleCommand(sql,con);
           // DataSet myset = new DataSet();
            
            OracleDataAdapter adapter = new OracleDataAdapter(cmd);
           // DataTable dt = new DataTable();
            adapter.Fill(dataSet1);
            this.dataGridView1.DataSource = dataSet1;
        }
    }
}
